package cn.tedu.demo.controller;

import cn.tedu.demo.pojo.entity.User;
import cn.tedu.demo.pojo.entity.UserInfo;
import cn.tedu.demo.pojo.vo.RoomTypeDetailListVO;
import cn.tedu.demo.pojo.vo.RoomTypeVO;
import cn.tedu.demo.service.IRoomTypeService;
import cn.tedu.demo.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Slf4j
@Api(tags="房型管理模块")
@RestController
@RequestMapping("/roomType")
public class RoomTypeController {

    @Autowired
    IRoomTypeService roomTypeService;
    @ApiOperation("根据id查询房型详情")
    @ApiOperationSupport(order=410)
    @GetMapping("/{id:[0-9]+}/get")
    public JsonResult<RoomTypeVO> get(@PathVariable Long id, HttpServletRequest request){
        log.debug("进入房型控制层，开始处理【根据id查询房型详情】的请求");
        RoomTypeVO roomTypeVO = roomTypeService.getStandardById(id,request);
        return JsonResult.ok(roomTypeVO);
    }
    @ApiOperation("查看房型列表")
    @ApiOperationSupport(order=420)
    @GetMapping("/list")
    public JsonResult<List<RoomTypeDetailListVO>> getList(){
        log.debug("进入房形控制层，开始处理【查询房型列表】的请求");
        List<RoomTypeDetailListVO> list = roomTypeService.getList();
        return JsonResult.ok(list);
    }
}
